<template>
  <div class="add box">
	  <div>
		  <p>
        &#12288;<i class="icon-bitian iconfont"></i>传输配置名称
			  <el-input v-model="detailList.name" placeholder="请输入传输配置名称" maxlength="30" size="normal"></el-input>
		  </p>
		  <p>
			  <i class="icon-bitian iconfont"></i>文件总大小(MB)
			  <span class="fixWidth">
          <el-input-number v-model="detailList.minFileSize" controls-position="right"  :min="0" :max="5120" size="normal"></el-input-number>
          <span>&nbsp;<s>&#12288;&#12288;</s>&nbsp;</span>
          <el-input-number v-model="detailList.maxFileSize" controls-position="right"  :min="detailList.minFileSize===0?1:detailList.minFileSize" :max="5120" size="normal"></el-input-number>
          <span class="limit"><i class="el-icon-warning-outline"></i>最大不超过5120</span>
        </span>
		  </p>
		  <p>
        &#12288;&#12288;&#12288;<i class="icon-bitian iconfont"></i>对象权限
			  <span class="fixWidth">
          <el-radio v-model="detailList.objectPermission" label="0" size="normal">私有</el-radio>
          <el-radio v-model="detailList.objectPermission" label="1" size="normal">公共读</el-radio>
        </span>
		  </p>
		  <p>
        &#12288;<i class="icon-bitian iconfont"></i>最大上传个数
			  <span class="fixWidth">
          <el-input-number v-model="detailList.maxUploadNumber" controls-position="right"  :min="1" :max="9" size="normal"></el-input-number>
        </span>
		  </p>
		  <p>
        &#12288;<i class="icon-bitian iconfont"></i>文件类型限制
			  <span class="fixWidth">
            <el-radio label="0" v-model="detailList.fileType" size="normal">图片</el-radio>
            <el-radio label="1" v-model="detailList.fileType" size="normal">视频</el-radio>
            <el-radio label="2" v-model="detailList.fileType" size="normal">图片和视频</el-radio>
        </span>
		  </p>
		  <p>
        &#12288;&#12288;&#12288;&#12288;&#12288;&#12288;备注
			  <el-input
					  type="textarea"
					  size="normal"
					  maxlength="100"
					  :autosize="{ minRows: 2, maxRows: 4}"
					  placeholder="请输入内容"
					  v-model="detailList.remarks"
					  resize="none">
			  </el-input>
		  </p>
      <p>
        <el-button type="primary" @click="addTrans" round size="normal">确认</el-button>
        <el-button round @click="()=>{$router.push('/configManage/transmissionConfig')}" size="normal">取消</el-button>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: "transmissionAdd",
  components:{},
  data(){
    return{
    	detailList:{
    		name:'',
		    minFileSize:0,
		    maxFileSize:0,
		    objectPermission:'',
		    maxUploadNumber:9,
		    fileType:'',
		    remarks:''
	    }
    }
  },
  methods:{
	  addTrans(){
		  if(this.verify()){
		  	this.$Http.transUpload(this.detailList).then(res =>{
		  		if (res.code === 'SUCCESS'){
		  			this.$message({
						  message:'增加成功！',
						  type:'success'
					  });
		  			this.$router.push('/configManage/transmissionConfig');
				  }else {
					  this.$message({
						  message:res.message,
						  type:'error'
					  });
				  }
			  })
		  }
	  },
	  // 校验
	  verify(){
		  if(this.detailList.name ===""){
			  this.$message.error("请填写传输配置名称");
			  return false;
		  }else if(this.detailList.fileType === ''){
			  this.$message.error("请选择文件类型");
			  return false;
		  }else if(this.detailList.objectPermission === ''){
			  this.$message.error("请选择对象操作权限");
			  return false;
		  }
		  else{
			  return true;
		  }
	  },
  }
}
</script>

<style scoped lang="scss">
@import "src/assets/css/content.scss";

</style>
